<template>
	<view class="select-type">
		
		<view class="goods">
			<view class="goods-info">
				<view class="goods-img">
					<image :src="goods.original_image" mode=""></image>
					
				</view>
				<view class="goods-name">{{goods.goods_name}}</view>
				<view class="spec-name">{{goods.spec_name}}</view>
			</view>
		</view>
		
		<view class="types">
			<view class="uni-list">
				<view class="uni-list-cell" v-for="(item,index) in types" :key="index" @tap="select_type(item)"> 
					<view class="uni-list-cell-navigate uni-navigate-right">
						<view class="text-danger iconfont" :class="item.icon_class"></view>
						<view class="info">
							<view class="type-name">{{item.title}}</view>
							<view class="type-tips">{{item.tips}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	
	</view>
</template>

<script>
	import Request from '../../common/request.js';
	
	export default {
		data() {
			return {
				get_datas: {},
				goods:'',
				after_type: '',
				types: [
					{id:1, title: '仅退款', tips:'未收到货(包含未签收)，或卖家协商同意前提下', icon_class:'icon-tuikuantuihuo'},
					{id:2, title: '退货退款', tips:'已收到货,需要退换已收到的货物', icon_class:'icon-servicewuyoutuihuanhuo1'},
				],
			};
		},
		onLoad(e) {
			this.get_datas = e;
			this.check_status();
		},
		methods: {
			//检查订单商品状态
			check_status: function(){
			    var that = this;
				Request.send({
					url: 'after_sales/check',
					data: {
						order_id: that.get_datas.order_id,
						item_id: that.get_datas.item_id
					},
					sCallback: function(res) {
						if(res.code == 200){
						    that.goods = res.data.goods;
						    if(that.goods.shipping_status == 2) {
						        that.types.push(
						            {id:3, title: '换货', tips:'已收到货,需要更换已收到的货', icon_class:'icon-quannianbaohuan'}
						        );
						    }
						} else if(res.code == 201) {
						    //存在示完成售后，到售后详情
						    
							uni.redirectTo({
								url: '/pages/aftersales/detail?id='+res.data.id
							})
						} else {
						    Request.alert(res.msg, () => {
						        uni.navigateBack({
						        	
						        })
						    })
						}
					}
				})
			},
			//选择售后类型
            select_type: function(item) {
			    var datas = this.get_datas;
			    var url = '/pages/aftersales/apply?order_id='+datas.order_id+'&item_id='+datas.item_id+'&after_type='+item.id;
				uni.redirectTo({
					url:url
				})
            }
		}
	}
</script>

<style>
	.goods-info{
		display: flex;
		flex-direction: row;
		padding: 20upx;
		background: #fff;
		margin-bottom: 10upx;
	}
	
	.goods-info .goods-img image{
		width: 120upx;
		height: 120upx;
	}
	
	.goods-info .goods-name{
		color: #666;
		padding-left: 20upx;
	}
	
	.types .iconfont{
		font-size: 80upx;
		margin-right: 10upx;
	}
	
	.types .uni-list-cell-navigate{
		justify-content: flex-start;
		padding: 0 30upx;
	}
	
	.types .type-tips{
		color: #666;
		font-size: 20upx;
	}
</style>
